package Sessions;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.jboss.ejb3.annotation.RemoteBinding;

/**
 * Session Bean implementation class AccettaAbilitaAdminSession
 */
@Stateless
@RemoteBinding(jndiBinding="AccettaAbilitaAdminSessionRemote")
public class AccettaAbilitaAdminSession implements AccettaAbilitaAdminSessionRemote {
	@PersistenceContext(unitName="swimv2")
	private EntityManager manager;
    public AccettaAbilitaAdminSession() {
        // TODO Auto-generated constructor stub
    }

	@Override
	public void aggiornaAbilitaAccettata(String idAbilita) {
		boolean valore = true;
		String s = "UPDATE Abilita a SET a.accettata=:valore WHERE a.id=:idAbilita";
		Query q = manager.createQuery(s);
		q.setParameter("idAbilita", idAbilita);
		q.setParameter("valore", valore);
		q.executeUpdate();
		manager.flush();
		
	}

	@Override
	public void eliminaAbilita(String idAbilita) {
		String s = "DELETE from Abilita a WHERE a.id=:idAbilita";
		Query q = manager.createQuery(s);
		q.setParameter("idAbilita", idAbilita);
		q.executeUpdate();
		manager.flush();
		
		
	}

}
